/* 
 * File:   encoder.hpp
 * Author: grm
 *
 * Created on 31 mars 2011, 22:09
 */

#ifndef ENCODER_HPP
#define	ENCODER_HPP


extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}

typedef struct {
    int size;
    uint8_t* buffer;
} image_buffer_t;

class Encoder {
private:
    char* workingDir;
    int width;
    int height;
    image_buffer_t* frame_to_external(AVFrame* pFrame, int width, int height, char* format);
    void SaveExternal(image_buffer_t* image, char* filename);
    void saveFrameToPPM(AVFrame *pFrame, FILE* pFile);

public:
    Encoder(char* workingDir, int width = 2048, int height = 1080);
    ~Encoder();
    void encode(AVFrame* frame, char* outfilename);
    int saveFrameToTiff(AVFrame* frame, char* filename);
    void encodeTiffInJ2K(char* input_file, char *out_file);
    void encodeFrameToJ2C(AVFrame* frame, char* outfilename);
};



#endif	/* ENCODER_HPP */

